package com.liu.yubi.bimq;

import com.liu.yubi.common.ErrorCode;
import com.liu.yubi.exception.BusinessException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author lqh
 * @since 2025-06-13 16:00
 * 生产者
 */
@Component
public class BiMessageProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    //发送消息
    public void sendMessage(String message) {
        try {
            rabbitTemplate.convertAndSend("YuBi_common_exchange","YuBi_common_key",message);
        }catch (Exception e){
            throw new BusinessException (ErrorCode.OPERATION_ERROR,"无法发送到指定队列");
        }

    }

    }

